﻿using System;

namespace AiAsteriods.Game.Entities.Agent {
  struct PosF {
    public float x;
    public float y;

    public float r { get { return y; } set { y = value; } }
    public float c { get { return x; } set { x = value; } }

    public static float MaxDist {
      get {
        PosF p = new PosF((float)Global.GameStart.ScreenWidth, (float)Global.GameStart.ScreenHeight);
        return p.DistTo(new PosF(0, 0));
      }
    }

    public static PosF Origin {
      get {
        return new PosF(Global.GameStart.ScreenWidth / 2.0f, Global.GameStart.ScreenHeight / 2.0f);
      }
    }

    public float rad {
      get {
        return (float)Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
      }
    }
    public float theta {
      get {
        return (float)Math.Atan(y / x);
      }
    }

    public static float MaxDistFromCenter {
      get {
        PosF c = new PosF(Global.GameStart.ScreenWidth / 2.0f, Global.GameStart.ScreenHeight / 2.0f);
        PosF p = new PosF(0, 0);

        return p.DistTo(c) + float.Epsilon;
      }
    }

    public PosF(float x, float y) {
      this.x = x;
      this.y = y;
    }

    public float DistTo(PosF p) {
      return (float)Math.Sqrt(Math.Pow(p.x - x, 2) + Math.Pow(p.y - y, 2));
    }
  }
}
